package com.le.book.Biz;

import java.sql.SQLException;
import java.util.Map;

import com.le.book.dao.ReaderDao;

public class ReaderBiz {
	
	private ReaderDao dao = new ReaderDao();
	
	public Map<String, Object> login(String name, String pwd) throws BizException{
		// 业务逻辑
		if(name == null || name.trim().isEmpty()) {
			throw new BizException("请填写用户名!");
		}
		
		if(pwd == null || pwd.trim().isEmpty()) {
			throw new BizException("请填写密码!");
		}
		
		try {
			Map<String, Object> reader = dao.selectForLogin(name, pwd);
			if(reader == null) {
				throw new BizException("用户名或密码错误！");
			}
			return reader;
		} catch(SQLException e) {
			throw new BizException("业务异常请联系管理员！", e);
		}
		
	}
	

}
